<template>
  <div class="app-container" style="background-color: #fafafb">
    <el-row type="flex" class="row-bg" justify="center">
      <el-col :span="24">
        <div class="grid-content bg-purple-light">
          <el-card class="box-card" shadow="never" style="margin-top: 0px; min-height: 918px;border:0px;">
            <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
              <el-menu-item index="1" v-permission="'system:credit-loan-list-history-list:access'">审批历史</el-menu-item>
              <el-menu-item index="2" v-permission="'system:credit-loan-customer-info-list:access'">客户信息</el-menu-item>
              <el-menu-item index="3" v-permission="'system:credit-loan-house-info-list:access'">资产信息</el-menu-item>
              <el-menu-item index="4" v-permission="'system:credit-loan-file-list:access'">附件信息</el-menu-item>
              <el-menu-item index="10" v-if="10 == itemActiveIndex" v-permission="'system:credit-loan-data-review:access'">资料复核</el-menu-item><!--资料复核-->
              <el-menu-item index="15" v-if="15 == itemActiveIndex" v-permission="'system:credit-loan-confirm-white-list:access'">确认白名单</el-menu-item><!--确认白名单-->
              <el-menu-item index="20"  v-if="20 == itemActiveIndex" v-permission="'system:credit-loan-app_review:access'">APP审核</el-menu-item><!--APP审核-->
              <el-menu-item index="25" v-if="25 == itemActiveIndex" v-permission="'system:credit-loan-sign_review:access'">预约面签</el-menu-item><!--预约面签-->
              <el-menu-item index="30" v-if="30 == itemActiveIndex" v-permission="'system:credit-loan-final_approval:access'">终审结果</el-menu-item><!--终审结果-->
              <el-menu-item index="80" v-if="80 == itemActiveIndex" v-permission="'system:credit-loan-draw_confirm_money:access'">提款确认</el-menu-item><!--提款确认-->
            </el-menu>
            <!--子组件展示-->
            <div style="margin: 50px">
              <ListHistory :projectId="projectId" v-if="activeIndex === '1'" />
              <Customer :projectId="projectId" :taskId="taskId" :isTaskProcessing="isTaskProcessing" :isProjectSubmit="isProjectSubmit" :projectStatus="18" v-if="activeIndex === '2'" />
              <Assets :projectId="projectId" :taskId="taskId"  :projectStatus="projectStatus" :isTaskProcessing="isTaskProcessing" :isProjectSubmit="isProjectSubmit" v-if="activeIndex === '3'" />
              <File changeValue="detail" :projectId="projectId" :taskId="taskId" :realName="realName" :isTaskProcessing="isTaskProcessing" :projectStatus="projectStatus" :isProjectSubmit="isProjectSubmit" v-if="activeIndex === '4'" />
              <DataReview :projectId="projectId" :taskId="taskId" :isTaskProcessing="isTaskProcessing" :currentNodeProjectStatus="10" v-if="activeIndex === '10'" /><!--资料复核审批-->
              <ConfirmWhiteList :projectId="projectId" :taskId="taskId" :isTaskProcessing="isTaskProcessing" :currentNodeProjectStatus="15"  v-if="activeIndex === '15'" /><!--确认白名单-->
              <AppReview :projectId="projectId" :taskId="taskId" :isTaskProcessing="isTaskProcessing" :currentNodeProjectStatus="20" v-if="activeIndex === '20'" /><!--APP审核-->
              <SignReview :projectId="projectId" :taskId="taskId" :isTaskProcessing="isTaskProcessing" :currentNodeProjectStatus="25" v-if="activeIndex === '25'" /><!--预约面签-->
              <FinalApproval :projectId="projectId" :taskId="taskId" :isTaskProcessing="isTaskProcessing" :currentNodeProjectStatus="30"  v-if="activeIndex === '30'" /><!--终审结果-->
              <ConfirmDrawMoney :projectId="projectId" :taskId="taskId" :isTaskProcessing="isTaskProcessing" :currentNodeProjectStatus="80"  v-if="activeIndex === '80' || activeIndex === '90'" /><!--提款确认-->
            </div>
          </el-card>
        </div></el-col
      >
    </el-row>
  </div>
</template>


<script>
import Customer from '@/views/credit/customer'
import Assets from '@/views/credit/assets'
import File from '@/views/credit/file'
import ListHistory from '@/views/task/credit_loan/listHistory'
import DataReview from '@/views/task/credit_loan/dataReview'
import ConfirmWhiteList from '@/views/task/credit_loan/confirmWhiteList'
import AppReview from '@/views/task/credit_loan/appReview'
import SignReview from '@/views/task/credit_loan/signReview'
import FinalApproval from '@/views/task/credit_loan/finalApproval'
import ConfirmDrawMoney from '@/views/task/credit_loan/confirmDrawMoney'
import {getProjectKey} from '@/utils/index'
import {findProjectBytId} from '@/api/project'
export default {
  name: 'add',
  components: {
    Customer,
    Assets,
    File,
    ListHistory,
    DataReview,
    ConfirmWhiteList,
    AppReview,
    SignReview,
    FinalApproval,
    ConfirmDrawMoney
  },
  data() {
    return {
      activeIndex: '1',
      itemActiveIndex: '1',
      name: '11',
      projectId: undefined,
      projectStatus: undefined,
      taskId: undefined,
      appointNextTime: undefined,
      ifReceive: undefined,
      isSubmit: undefined,
      isTaskProcessing: undefined,
      isProjectSubmit: undefined,
      isNeedFirstSubmit: undefined,
      realName:undefined,
      projectKey:undefined
    };
  },
  computed: {},
  created() {
    this.projectId = this.$route.query.projectId
    this.projectStatus = this.$route.query.projectStatus
    this.taskId = this.$route.query.taskId
    this.appointNextTime = this.$route.query.appointNextTime
    this.ifReceive = ''+this.$route.query.ifReceive+''
    this.isSubmit = this.$route.query.isSubmit
    this.isTaskProcessing = this.$route.query.isTaskProcessing
    this.isNeedFirstSubmit = this.$route.query.isTaskProcessing
    this.isProjectSubmit = this.$route.query.isProjectSubmit
    this.realName = this.$route.query.realName
    // this.findByProjectId()
    if (this.ifReceive == 0) {
      // 已处理的任务默认展示第一个
      this.activeIndex == '1';
    } else {
      if (this.projectStatus != undefined) {
        this.itemActiveIndex = '' + this.projectStatus + ''
        this.activeIndex = '' + this.projectStatus + ''
      }
    }
    console.log('activeIndex:' + this.activeIndex)
    //点击详情进来
    let lookIndex = this.$route.query.activeIndex
    if( lookIndex != undefined ) {
      this.activeIndex = lookIndex
    }
  },
  methods: {
    stepChange(currentStep) {
      this.currentStep = currentStep;
    },
    handleSelect(val) {
      // if (this.isNeedFirstSubmit == true){
      //   if (this.itemActiveIndex != val){
      //     this.isTaskProcessing = false;
      //   }else{
      //     this.isTaskProcessing = this.isNeedFirstSubmit;
      //   }
      // }
      this.activeIndex = val;
    },
    matchState(state='',reg) {
      return !!String(state).match(reg)
    },
    findByProjectId() {
      findProjectBytId({projectId:this.projectId})
        .then(response => {
          if(response.data != undefined ) {
           console.log(response.data)
           let key = getProjectKey(response.data.processKey)
           this.projectKey = key
          }
        })
        .catch(() => {
        })
    },
  },
};
</script>



